<?php

	/**
	 * @see Bike_Initial
	 */
	require_once 'Bike/Initial.php';
	
	/**
	 * @see Zend_Loader
	 */
	require_once 'Zend/Loader.php';
	
	
	abstract class Bike_Form_Renderer extends Bike_Initial
	{        const TYPE = 'Standard';

        protected $_element;

        static public function getRendererClassName($RenderType)
		{
			return __CLASS__.'_'.$RenderType;
		}

        static public function factory($Element, $RenderType=self::TYPE)
        {        	$className = self::getRendererClassName($RenderType);
        	try
			{
				@Zend_Loader::loadClass($className);
			}
			catch(Zend_Exception $e)
			{
				require_once 'Bike/Form/Renderer/Exception.php';
				throw new Bike_Form_Renderer_Exception('Class "'.$className.'" is undefined');
			}
        	$Renderer = new $className();
        	if(!$Renderer instanceof self)
        	{        		require_once 'Bike/Form/Renderer/Exception.php';
        		throw new Bike_Form_Renderer_Exception('Class "'.$className.'" is not instance of '.__CLASS__);
        	}
        	$Renderer->setElement($Element);
        	return $Renderer;
        }

        public function setElement($Element)
        {        	$this->_element = $Element;
        	return $this;
        }

        public function getElement()
        {        	return $this->_element;
        }

        abstract public function render(Zend_View_Interface $View = null);
	}
